<?php
class Application{
	function bsVndDot($strNum)
	{	
		if (strpos($strNum,'-') !== false) {
			$strNum = substr($strNum, 1);
			$len = strlen($strNum);
			$counter = 3;
			$result = "";
			while ($len - $counter >= 0)
			{
				$con = substr($strNum, $len - $counter , 3);
				$result = '.'.$con.$result;
				$counter+= 3;
			}
			$con = substr($strNum, 0 , 3 - ($counter - $len) );
			$result = $con.$result;
			if(substr($result,0,1)=='.'){
				$result=substr($result,1,$len+1);   
			}
			return "<b style='color:red'>- " . $result . "</b>";
		}else
		{
			$len = strlen($strNum);
			$counter = 3;
			$result = "";
			while ($len - $counter >= 0)
			{
				$con = substr($strNum, $len - $counter , 3);
				$result = '.'.$con.$result;
				$counter+= 3;
			}
			$con = substr($strNum, 0 , 3 - ($counter - $len) );
			$result = $con.$result;
			if(substr($result,0,1)=='.'){
				$result=substr($result,1,$len+1);   
			}
			return $result;
		}
	}
	function CatChim($str, $len) { 
		$str = trim($str); 
		if (strlen($str) <= $len) return $str; 
		$str = substr($str, 0, $len); 
		if ($str != "") { 
			if (!substr_count($str, " ")) return $str." ..."; 
			while (strlen($str) && ($str[strlen($str) - 1] != " ")) $str = substr($str, 0, -1); 
			$str = substr($str, 0, -1)." ..."; 
		} 
		return $str; 
	} 
	public function getURL($theloai_id)
	{
		$arr_tintuc = array(
			'gioithieu' => array(1,2,3),
			'thongtin' => array(4,5,6,7,8,9,10,11,12,13,14,15,16),
			'hoatdong' => array(18,19,20),
			'hoivien' => array(21,22,23,24,25,26,27),
			'thuvien' => array(28,29,30,31,32,33)
		);
		foreach ($arr_tintuc as $n=>$c)
		  if (in_array($theloai_id, $c)) {
			$arr_tintuc=$n;
			break;
		  }
		return $arr_tintuc;
	}
}	
?>